
//快速选择排序


#include <iostream>
using namespace std;

const int N = 100010 ;

int q[N];
int n, k;

//关键是分情况进行递归   
//两种情况：
//k<=Sl(枢轴左边的个数),递归left
//k>Sl,递归right,k-Sl
int quick_sort(int l, int r, int k){
    if(l == r)    return q[l];

    int x = q[l], i = l -1, j = r + 1;
    while(i < j){
        do i++; while(q[i] < x);
        do j--; while(q[j] > x);
        if(i < j) swap(q[i], q[j]);
    }
    if(j - l + 1 >= k)   return quick_sort(l, j, k);
    else return quick_sort(j + 1 , r, k - (j - l + 1));

}

int main(){

    scanf("%d%d", &n, &k);

    for(int i = 0; i < n; i ++)      scanf("%d", &q[i]);

    cout << quick_sort(0, n - 1, k) << endl;

    return 0;


}